<?php

class FlashBox extends CWidget {
	
	public $listen = array(
		FLASH::RESULT_SUCCESS,
		FLASH::RESULT_FAILED,
		FLASH::RESULT_WARNING,
		FLASH::RESULT_INFO,
	);
	
	public function run() {
		
		$classes = array(
			FLASH::RESULT_FAILED => 'errormsg',
			FLASH::RESULT_SUCCESS => 'success',
			FLASH::RESULT_WARNING => 'warning',
			FLASH::RESULT_INFO => 'info',
		);
		
		foreach($this->listen as $one) {
			$message = Yii::app()->user->getFlash($one);
			if(!$message) continue;
			$class = $classes[$one];
			$this->renderFile(dirname(__FILE__).'/templates/flashBox/default.php', array(
				'class' => $class,
				'message' => $message,
			));
		}
			
	}
	
}

?>